{"ast":null,"code":"import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nvar Record;\n(function (Record) {\n  Record[Record[\"None\"] = 0] = \"None\";\n  Record[Record[\"Start\"] = 1] = \"Start\";\n  Record[Record[\"End\"] = 2] = \"End\";\n})(Record || (Record = {}));\nfunction traverseNodesKey(treeData, callback) {\n  function processNode(dataNode) {\n    var key = dataNode.key,\n      children = dataNode.children;\n    if (callback(key, dataNode) !== false) {\n      traverseNodesKey(children || [], callback);\n    }\n  }\n  treeData.forEach(processNode);\n}\n/** 计算选中范围，只考虑expanded情况以优化性能 */\nexport function calcRangeKeys(_ref) {\n  var treeData = _ref.treeData,\n    expandedKeys = _ref.expandedKeys,\n    startKey = _ref.startKey,\n    endKey = _ref.endKey;\n  var keys = [];\n  var record = Record.None;\n  if (startKey && startKey === endKey) {\n    return [startKey];\n  }\n  if (!startKey || !endKey) {\n    return [];\n  }\n  function matchKey(key) {\n    return key === startKey || key === endKey;\n  }\n  traverseNodesKey(treeData, function (key) {\n    if (record === Record.End) {\n      return false;\n    }\n    if (matchKey(key)) {\n      // Match test\n      keys.push(key);\n      if (record === Record.None) {\n        record = Record.Start;\n      } else if (record === Record.Start) {\n        record = Record.End;\n        return false;\n      }\n    } else if (record === Record.Start) {\n      // Append selection\n      keys.push(key);\n    }\n    return expandedKeys.includes(key);\n  });\n  return keys;\n}\nexport function convertDirectoryKeysToNodes(treeData, keys) {\n  var restKeys = _toConsumableArray(keys);\n  var nodes = [];\n  traverseNodesKey(treeData, function (key, node) {\n    var index = restKeys.indexOf(key);\n    if (index !== -1) {\n      nodes.push(node);\n      restKeys.splice(index, 1);\n    }\n    return !!restKeys.length;\n  });\n  return nodes;\n}","map":{"version":3,"names":["_toConsumableArray","Record","traverseNodesKey","treeData","callback","processNode","dataNode","key","children","forEach","calcRangeKeys","_ref","expandedKeys","startKey","endKey","keys","record","None","matchKey","End","push","Start","includes","convertDirectoryKeysToNodes","restKeys","nodes","node","index","indexOf","splice","length"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/antd/es/tree/utils/dictUtil.js"],"sourcesContent":["import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nvar Record;\n(function (Record) {\n  Record[Record[\"None\"] = 0] = \"None\";\n  Record[Record[\"Start\"] = 1] = \"Start\";\n  Record[Record[\"End\"] = 2] = \"End\";\n})(Record || (Record = {}));\nfunction traverseNodesKey(treeData, callback) {\n  function processNode(dataNode) {\n    const {\n      key,\n      children\n    } = dataNode;\n    if (callback(key, dataNode) !== false) {\n      traverseNodesKey(children || [], callback);\n    }\n  }\n  treeData.forEach(processNode);\n}\n/** 计算选中范围，只考虑expanded情况以优化性能 */\nexport function calcRangeKeys(_ref) {\n  let {\n    treeData,\n    expandedKeys,\n    startKey,\n    endKey\n  } = _ref;\n  const keys = [];\n  let record = Record.None;\n  if (startKey && startKey === endKey) {\n    return [startKey];\n  }\n  if (!startKey || !endKey) {\n    return [];\n  }\n  function matchKey(key) {\n    return key === startKey || key === endKey;\n  }\n  traverseNodesKey(treeData, key => {\n    if (record === Record.End) {\n      return false;\n    }\n    if (matchKey(key)) {\n      // Match test\n      keys.push(key);\n      if (record === Record.None) {\n        record = Record.Start;\n      } else if (record === Record.Start) {\n        record = Record.End;\n        return false;\n      }\n    } else if (record === Record.Start) {\n      // Append selection\n      keys.push(key);\n    }\n    return expandedKeys.includes(key);\n  });\n  return keys;\n}\nexport function convertDirectoryKeysToNodes(treeData, keys) {\n  const restKeys = _toConsumableArray(keys);\n  const nodes = [];\n  traverseNodesKey(treeData, (key, node) => {\n    const index = restKeys.indexOf(key);\n    if (index !== -1) {\n      nodes.push(node);\n      restKeys.splice(index, 1);\n    }\n    return !!restKeys.length;\n  });\n  return nodes;\n}"],"mappings":"AAAA,OAAOA,kBAAkB,MAAM,8CAA8C;AAC7E,IAAIC,MAAM;AACV,CAAC,UAAUA,MAAM,EAAE;EACjBA,MAAM,CAACA,MAAM,CAAC,MAAM,CAAC,GAAG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